package org.come.Frame;

import java.awt.event.MouseEvent;
import java.awt.event.MouseListener;
import java.awt.event.MouseMotionListener;

import javax.swing.BorderFactory;
import javax.swing.JInternalFrame;
import javax.swing.WindowConstants;
import javax.swing.plaf.basic.BasicInternalFrameUI;

import org.come.Jpanel.FindDropJpanel;
import org.come.until.FormsManagement;
import org.come.until.MessagrFlagUntil;
import org.come.until.Music;

import com.tool.tcpimg.UIUtils;

//TODO 查询面板（父）
/**
 *
 * @author gl
 *
 */
public class FindDropJfram extends JInternalFrame implements MouseListener {

	private static final long serialVersionUID = 1L;
	private FindDropJpanel findDropJpanel;// 查询面板
    public FindDropJpanel getFindDropJpanel() {
		return findDropJpanel;
	}

	public void setFindDropJpanel(FindDropJpanel findDropJpanel) {
		this.findDropJpanel = findDropJpanel;
	}

	private int first_x, first_y;// x、y坐标

    public static FindDropJfram getFindDropJfram() {

        return (FindDropJfram) FormsManagement.getInternalForm(600).getFrame();
    }

    public FindDropJfram() throws Exception {
    	findDropJpanel = new FindDropJpanel();
        this.getContentPane().add(findDropJpanel);
        this.setBounds(300, 200, 296, 257);
        this.setBorder(BorderFactory.createEmptyBorder());// 去除内部窗体的边框
        ((BasicInternalFrameUI) this.getUI()).setNorthPane(null);// 去除顶部的边框

        this.addMouseListener(this);
        this.addMouseMotionListener(new MouseMotionListener() {// 判断窗口移动的位置

            @Override
            public void mouseMoved(MouseEvent e) {
                if (MessagrFlagUntil.ImgFlagImg.equals(MessagrFlagUntil.MOUSE13)) {
                    MessagrFlagUntil.setMouse(MessagrFlagUntil.MOUSE1);
                }
            }

            @Override
            public void mouseDragged(MouseEvent e) {
                if (isVisible()) {
                    int x = e.getX() - first_x;
                    int y = e.getY() - first_y;
                    setBounds(x + getX(), y + getY(), getWidth(), getHeight());
                }
            }
        });

        this.setBackground(UIUtils.Color_BACK);
        this.pack();
        this.setVisible(false);
        this.setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE);
    }

    @Override
    public void mousePressed(MouseEvent e) {
        // TODO Auto-generated method stub
        // 开启窗口音效
        Music.addyinxiao("关闭窗口.mp3");
        // 打开了窗体
        if (e.isMetaDown()) {// 检测鼠标右键单击
            FormsManagement.HideForm(112);
        }
        this.first_x = e.getX();
        this.first_y = e.getY();

    }

    @Override
    public void mouseClicked(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseReleased(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseEntered(MouseEvent e) {
        // TODO Auto-generated method stub

    }

    @Override
    public void mouseExited(MouseEvent e) {
        // TODO Auto-generated method stub

    }
}
